package com.asiainfo.service;
/*
 * 
 * 教练操作service
 */
import com.asiainfo.bean.Coach;
import com.asiainfo.dao.Coach_Dao;

public class CoachService {
	//增加教练
	public void addCoach(String[] args){
		if(args.length != 5){
			System.out.println("对不起，请输入合法参数");
			return;
		}
		Coach coach = new Coach(args[1],args[2],args[4],Integer.parseInt(args[3]));
		Coach_Dao cd = new Coach_Dao();
		Coach findcoach = cd.findcoachByName(coach.getCoach_name());
		if(findcoach!=null){
			System.out.println("该教练已存在");
		}else{
			int result = cd.addcoach(coach);
			if(result>0){
				System.out.println("教练【"+coach.getCoach_name()+"】添加成功");
			}else{
				System.out.println("教练添加失败");
			}
		}
	}
	//根据姓名查找教练
	public Coach findCoachByName(String coachName){
		Coach_Dao cd = new Coach_Dao();
		return cd.findcoachByName(coachName);
	}
	//根据ID查找教练
	public Coach findCoachById(int id){
		Coach_Dao cd = new Coach_Dao();
		return cd.findcoachById(id);
	}
}
